package com.yumeng.ui.controller;

import com.yumeng.ui.bean.TestVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author wxd
 * @date 2025/11/13 10:57
 */
@Controller
@RequestMapping("/ym/page/demo")
public class YmDemoTemplatesController {

    /**
     * 测试thymeleaf
     */
    @GetMapping("/testThymeleaf.vw")
    public ModelAndView testThymeleaf(){
        Map<String, Object> map = new HashMap<>();
        map.put("name", "你好，管理员！");
        map.put("welcomewords", "欢迎使用Thymeleaf！");
        map.put("welcomewords2", "<b>欢迎使用Thymeleaf！</b>");
        map.put("url", "https://www.w3xue.com/");
        map.put("jsstr", "w3xue教程Thymeleaf的使用\n我是欢迎使用Thymeleaf传给JS执行的变量！");
        map.put("jsstr2", 3);

        List<TestVo> tests = TestVo.initTestData();
        map.put("tests", tests);
        map.put("test", tests.get(0));

        List<String> nameList = new ArrayList<>();
        nameList.add("1");
        nameList.add(null);

        map.put("nameList", nameList);
        //ContextAdapter.dataFormat(map);
        return new ModelAndView("demo/demo_thymeleaf", map);
    }

    /**
     * 测试layui
     *
     * @return
     */
    @GetMapping("/testLayui.vw")
    public String testLayui(){
        return "demo/demo_layui";
    }

}
